package demo.platform;

import java.awt.Image;
import java.awt.Rectangle;

import javax.swing.ImageIcon;

public class Tile {

	private int x,y;
	private int width,height;
	private String path_to_tile;
	private boolean solid;
	private Image tile_image;
	
	public Tile() {
		
	}
	
	public Tile(String path) {
		path_to_tile = path;
		loadImage();
	}
	
	public Tile(int tx, int ty, String path) {
		x  = tx;
		y  = ty;
		path_to_tile = path;
		loadImage();
		
	}
	
	private void loadImage() {
		ImageIcon ti = new ImageIcon("res/Tiles/"+path_to_tile);
		tile_image = ti.getImage();
		width = tile_image.getWidth(null);
		height = tile_image.getHeight(null);
		
	}
	
	public boolean isSolid() {
		return solid;
	}
	
	public Rectangle getTileBounds() {
		return new Rectangle(x,y,width,height);
	}
	
	/**
	 * Returns tile Image.
	 * @return
	 */
	public Image getTile() {
		return tile_image;
	}
	
	public int getX() {
		return x;
	}
	
	public int getY() {
		return y;
	}
	
	public void setX(int newx) {
		x = newx;
	}
	
	public void setY(int newy) {
		y = newy;
	}
	
	public void setTileSolid(boolean isSolid) {
		solid = isSolid;
	}
	
}
